package com.goodving.guli.activity;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LayoutAnimationController;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C0708b;
import com.goodving.guli.bt.DimPanelFragment;
import com.goodving.guli.bt.DynamicManager;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.dataprocess.SportDay;
import com.goodving.guli.bt.eventbus.EventApkupgrade;
import com.goodving.guli.bt.eventbus.EventBtOnOff;
import com.goodving.guli.bt.eventbus.EventDynamicDetailSleepUserModified;
import com.goodving.guli.bt.eventbus.EventGoalsUpdated;
import com.goodving.guli.bt.eventbus.EventHomeListLoad;
import com.goodving.guli.bt.eventbus.EventLuaUpdated;
import com.goodving.guli.bt.eventbus.EventPersonInfoUpdateUnit;
import com.goodving.guli.bt.eventbus.EventTimeChanged;
import com.goodving.guli.bt.eventbus.EventUseManualLazyDay;
import com.goodving.guli.bt.eventbus.EventUserChanged;
import com.goodving.guli.bt.eventbus.EventUserDeleted;
import com.goodving.guli.bt.eventbus.EventWeightChanged;
import com.goodving.guli.bt.eventbus.EventWeightSyncedDevice;
import com.goodving.guli.bt.eventbus.EventWeightSyncedServer;
import com.goodving.guli.bt.eventbus.EventWeightTargetUpdated;
import com.goodving.guli.bt.eventbus.EventWeightWithUser;
import com.goodving.guli.bt.eventbus.ThirdTokenState;
import com.goodving.guli.bt.lua.DaoManager;
import com.goodving.guli.bt.lua.LuaEvent;
import com.goodving.guli.bt.lua.SlidingUpPanelLayout;
import com.goodving.guli.bt.lua.SlidingUpPanelLayout.PanelSlideListener;
import com.goodving.guli.bt.model.DataManager;
import com.goodving.guli.bt.model.HwBatteryStatus;
import com.goodving.guli.bt.model.HwSyncDataStatus;
import com.goodving.guli.bt.model.LuaItem;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.model.WeightInfo;
import com.goodving.guli.bt.model.WeightInfoManager;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.C3843c;
import com.goodving.guli.bt.profile.scale.HwConnStatus;
import com.goodving.guli.bt.profile.scale.XMBLEManager;
import com.goodving.guli.bt.utils.WeightUtil;
import com.goodving.guli.bt.weight.LuaUtil;
import com.goodving.guli.bt.weight.UserInfoManager;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.utility.gulihardware.Constant;
import com.goodving.guli.view.BitmapDescriptorFactory;
import com.goodving.guli.view.C0804t;
import com.goodving.guli.view.C3247b;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;
import com.goodving.guli.view.DynamicFragment;
import com.goodving.guli.view.LuaListAdapter;
import com.goodving.guli.view.MyListView;

import java.net.URISyntaxException;
import java.util.List;
import java.util.Locale;

import cn.com.smartdevices.bracelet.chart.util.ChartData;
import cn.com.smartdevices.bracelet.config.Config;
import cn.com.smartdevices.bracelet.config.C0886a;

/**
 * Created by john on 2015/12/1.
 */
public class ScaleActivity extends BaseSCActivity implements View.OnClickListener {
    private static final int f9031I = 0;
    private static final int f9032J = 1;
    private static final int f9033K = 60000;
    private static final int f9034L = 272;
    private static final int f9035M = 273;
    private static final int f9036N = 274;
    private static final int f9037O = 0;
    private static final int f9038P = 2;
    private static final int f9039Q = 3;
    private static final int f9040R = 378;
    private static final int f9041S = 33;
    private static final int f9042T = 33;
    private static final int f9043U = 100;
    public static final int f9044b = 2000;
    public static final int f9045c = 520;
    private static final String TAG = "ScaleActivity";
    private static final int f9047e = 5;
    private static final boolean f9048f = false;
//    private MedalManager f9049A;
//    private ShareDataManager f9050B;
//    private FwUpgradeManager f9051C;
    private long f9052D;
    private Context mContext;
    private final Config f9054F;
    private boolean f9055G;
    private Resources f9056H;
    private SlidingUpPanelLayout mSlidingUpPanelLayout;
    private View f9058W;
    private View f9059X;
    private View f9060Y;
    private ImageView f9061Z;
    private int aA;
    private int aB;
    private ProgressBar progressBar1;
    private TextView tMsg1;
    private TextView tMsg2;
    private MyListView mMyListView;
    private TextView ae;
    private LuaListAdapter mLuaListAdapter;
    private boolean ag;
    private float ah;
    private int ai;
    private boolean aj;
    private float ak;
    private final float al;
    private int am;
    private int an;
    private int ao;
    private int ap;
    private int aq;
    private final float ar;
    private boolean as;
    private boolean at;
    private boolean au;
    private boolean av;
    private ValueAnimator aw;
    private ValueAnimator ax;
    private ValueAnimator ay;
    private final PanelSlideListener mPanelSlideListener;
    private View headerNavLeft;
    private View headerNavRight;
    private TextView dynamicTitle;
    private TextView dynamicSubtitle;
    private DynamicFragment mDynamicFragment;
    private MainMenuFragment mMainMenuFragment;
    private boolean f9068m;
    private boolean f9069n;
    private boolean f9070o;
    private boolean f9071p;
    private boolean f9072q;
    private Handler mHandler;
    private HwSyncDataStatus mHwSyncDataStatus;
    private BroadcastReceiver mBroadcastReceiver;
//    private C1492h f9076u;
//    private C1429e f9077v;
//    private WeatherManager f9078w;
//    private GameManager f9079x;
//    private PartnerDataManager f9080y;
    private HwConnStatus mHwConnStatus;

    class bW implements PanelSlideListener {
        final /* synthetic */ ScaleActivity f9686a;

        bW(ScaleActivity mainUIActivity) {
            this.f9686a = mainUIActivity;
        }
        public void onPanelHidden(View panel)
        {

        }
        public int onGetPullDownDistance() {
            return this.f9686a.aq;
        }

        public Boolean onGetPullDownDockEnable() {
            GuliLog.tracePrintInfo("ScaleActivity", "res:" + this.f9686a.aj + "," + this.f9686a.f9070o + "," + DeviceSource.hasBindDevice());
            return this.f9686a.aj ? Boolean.valueOf(true) : !this.f9686a.f9070o ? Boolean.valueOf(false) : Boolean.valueOf(DeviceSource.hasBindDevice());
        }

        public float onGetThreshhold() {
            return this.f9686a.ak;
        }

        public float onGetThreshhold2() {
            return 1.27f;
        }

        public void onLastSlideOffset(View view, float f) {
            GuliLog.tracePrintInfo("ScaleActivity", "onLastSlideOffset:  lastOffset " + f);
            if (f > this.f9686a.ak) {
                GuliLog.m12370d("ScaleActivity", "\nisBinded:" + Utils.m8065e() + ",isBtOff:" + this.f9686a.f9072q + ",isTimeoutTips:" + this.f9686a.au + ",isConnected:" + XMBLEManager.m25158c() + ",isNeedSyncData:" + this.f9686a.f9070o);
                if (DeviceSource.hasBindBracelet()) {
                    HwConnStatus k = XMBLEManager.m25166k();
                    if (this.f9686a.f9072q) {
                        this.f9686a.m13662c(true);
                    } else if (this.f9686a.au) {
                        this.f9686a.m13859M();
                        this.f9686a.mHandler.sendEmptyMessage(273);
                    } else if (this.f9686a.f9070o) {
//                        new C3839z(new C0639F(this.f9686a.mContext)).m9824f();
//                        C0668a.m8128a(this.f9686a, C0668a.da, C0668a.dc);
                    } else if (k.m25403f()) {
//                        C3844a.m25151a(null, true, Utils.m8093p());
//                        C0668a.m8128a(this.f9686a, C0668a.da, C0668a.dd);
                    }
                } else if (DeviceSource.hasBindShoesDevice()) {
//                    if (this.f9686a.f9072q) {
//                        this.f9686a.m13662c(true);
//                    } else if (this.f9686a.av || this.f9686a.au) {
//                        this.f9686a.av = false;
//                        this.f9686a.m13859M();
//                        this.f9686a.mHandler.sendEmptyMessage(UserInfoFragment.f11478d);
//                    } else if (C3843c.SHOES.equals(this.f9686a.mHwConnStatus.m25399b()) && this.f9686a.mHwConnStatus.m25408k()) {
//                        if (!this.f9686a.m13656a(true)) {
//                            this.f9686a.m13906e(true);
//                        }
//                    } else if (this.f9686a.f9070o) {
//                        this.f9686a.m13906e(true);
//                    }
                } else if (DeviceSource.hasBindSensorHub()) {
//                    C1218a.m11319a().m11336a(this.f9686a.mContext, new C0639F(this.f9686a.mContext, true));
                }
//                this.f9686a.f9080y.loadHomeMessageList();
            }
        }

        public void onPanelAnchored(View view) {
            GuliLog.tracePrintInfo("ScaleActivity", "onPanelAnchored");
        }

        public void onPanelCollapsed(View view) {
            GuliLog.tracePrintInfo("ScaleActivity", "onPanelCollapsed");
            this.f9686a.ag = true;
            this.f9686a.mSlidingUpPanelLayout.setSlidingEnabled(true);
            this.f9686a.mMyListView.setSelectionAfterHeaderView();
        }

        public void onPanelExpanded(View view) {
            GuliLog.tracePrintInfo("ScaleActivity", "onPanelExpanded");
            this.f9686a.ag = false;
        }

//        //TBD
//        public void onPanelSlide(View view, float f) {
//
//        }
        public void onPanelSlide(View view, Boolean bool, float f) {
            GuliLog.tracePrintInfo("ScaleActivity", "onPanelSlide, slideOffset=" + f + " Pressed: " + bool);
            if (f <= 1.0f) {
                if (this.f9686a.mDynamicFragment != null) {
                    this.f9686a.mDynamicFragment.m14459a(f);
                }
                if (f == 0.0f) {
                    C0668a.m8128a(this.f9686a, C0668a.da, C0668a.db);
                }
            } else {
                this.f9686a.mDynamicFragment.m14459a(1.0f);
                if (bool.booleanValue()) {
                    this.f9686a.ae.setVisibility(View.GONE);
                    if (!(this.f9686a.aj && this.f9686a.ai == 1)) {
                        if (f < this.f9686a.ak) {
                            this.f9686a.m13893a(this.f9686a.getString(R.string.dynamic_pull_pull_to_sync), Utils.m7976a(this.f9686a, (int) R.string.dynamic_pull_last_sync_time), 0, f);
                            this.f9686a.f9061Z.setRotation(0.0f);
                        } else {
                            if (this.f9686a.ah < this.f9686a.ak) {
                                this.f9686a.m13865P();
                            }
                            HwSyncDataStatus hwSyncDataStatus = null; //C0639F.f3447b;
                            GuliLog.m12370d("ScaleActivity", "hds:" + hwSyncDataStatus + ",status:" + XMBLEManager.m25158c());
                            this.f9686a.f9070o = false;
                            if ((XMBLEManager.m25158c() && !hwSyncDataStatus.m25418e()) || DeviceSource.hasBindSensorHub()) {
                                this.f9686a.f9070o = true;
                            } else if (DeviceSource.hasBindShoesDevice() && C3843c.SHOES.equals(this.f9686a.mHwSyncDataStatus.m25421h()) && !this.f9686a.mHwSyncDataStatus.m25418e()) {
                                this.f9686a.f9070o = true;
                            }
                            this.f9686a.m13893a(this.f9686a.getString(R.string.dynamic_pull_release_to_sync), Utils.m7976a(this.f9686a, (int) R.string.dynamic_pull_last_sync_time), 0, f);
                        }
                    }
                }
            }
            this.f9686a.ah = f;
        }
    }

    public ScaleActivity() {
        this.mHwSyncDataStatus = new HwSyncDataStatus();
        this.mHwConnStatus = new HwConnStatus();
        this.f9052D = -1;
        this.f9054F = Config.m8876h();
        this.f9056H = null;
        this.ag = true;
        this.ah = 1.0f;
        this.ai = -1;
        this.ak = 1.3f;
        this.al = 1.27f;
        this.am = 300;
        this.an = 1150;
        this.ao = f9043U;
        this.ap = 200;
        this.aq = 400;
        this.ar = 800.0f;
        this.mPanelSlideListener = new bW(this);
        this.aA = -1;
        this.aB = f9037O;
    }

    private void m13834A() {
        if (!this.f9072q) {
            if (DeviceSource.hasBindBracelet() || DeviceSource.hasBindShoesDevice()) {
                this.mHandler.sendEmptyMessage(f9035M);
            }
        }
    }

    private void m13836B() {
        updateTitle(R.string.battery_low_info);
    }

    private void onStatisticActivity() {
        Intent intent = new Intent(this, StatisticActivity.class);
        intent.putExtra(ChartData.KEY_MODE, ChartData.m8731a().m8817u());
        startActivity(intent);
        if (ChartData.m8731a().m8817u() == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            C0668a.m8126a(this.mContext, C0668a.fR);
        }
        if (ChartData.m8731a().m8817u() == f9032J && DataManager.m12179a().m12239r() == f9039Q) {
            C0668a.m8126a(this.mContext, C0708b.bE);
        }
    }

    static class cz implements MainMenuFragment.bS {
        final /* synthetic */ ScaleActivity f9844a;

        cz(ScaleActivity mainUIActivity) {
            this.f9844a = mainUIActivity;
        }

        public void m14498a() {
            this.f9844a.f9068m = false;
            if (C3246a.m22924b(this.f9844a.mContext)) {
                this.f9844a.getWindow().getDecorView().destroyDrawingCache();
                return;
            }
            View findViewById = this.f9844a.findViewById(Window.ID_ANDROID_CONTENT);
            if (findViewById != null) {
                findViewById.destroyDrawingCache();
            }
        }
    }

    // setting more
    private void onMainMenuFragment() {
        if (!this.f9068m) {
            Bitmap drawingCache;
            this.f9068m = true;
            if (this.mMainMenuFragment == null) {
                this.mMainMenuFragment = (MainMenuFragment) Fragment.instantiate(this.mContext, MainMenuFragment.class.getName());
                this.mMainMenuFragment.m14494a(new cz(this));
            }
            GuliLog.tracePrintInfo(TAG, "CurrentMode() " + ChartData.m8731a().m8817u());
            GuliLog.tracePrintInfo(TAG, "LastShownData().userId " + this.mDynamicFragment.m14471g().f11135c);
            GuliLog.tracePrintInfo(TAG, "LastShownData().advData.toJsonString() " + this.mDynamicFragment.m14471g().weightInfo.m25503n());
            Bundle bundle = new Bundle();
            if (this.mDynamicFragment.m14470f().f11135c == 0) {
                bundle.putInt(ChartData.KEY_MODE, ChartData.m8731a().m8817u());
                bundle.putInt(ChartData.f4056k, this.mDynamicFragment.m14471g().f11135c);
                bundle.putString(ChartData.f4057l, this.mDynamicFragment.m14471g().weightInfo.m25503n());
            } else {
                bundle.putInt(ChartData.KEY_MODE, ChartData.m8731a().m8817u());
                bundle.putInt(ChartData.f4056k, this.mDynamicFragment.m14470f().f11135c);
                bundle.putString(ChartData.f4057l, this.mDynamicFragment.m14470f().weightInfo.m25503n());
            }
            this.mMainMenuFragment.setArguments(bundle);
            View decorView;
            if (C3246a.m22924b(this.mContext)) {
                decorView = getWindow().getDecorView();
                decorView.buildDrawingCache();
                drawingCache = decorView.getDrawingCache();
            } else {
                decorView = findViewById(Window.ID_ANDROID_CONTENT); // 16908290
                if (decorView != null) {
                    decorView.buildDrawingCache();
                    drawingCache = decorView.getDrawingCache();
                } else {
                    drawingCache = null;
                }
            }
            this.mMainMenuFragment.m14493a(drawingCache);
            FragmentTransaction beginTransaction = getFragmentManager().beginTransaction();
            beginTransaction.addToBackStack(null);
            this.mMainMenuFragment.show(beginTransaction, null);
            C0668a.m8126a((Context) this, C0668a.df);
        }
    }

    private void m13843E() {
        m13908f(true);
        this.am = f9037O;
        this.an = (int) Utils.m8026b(378.0f, (Context) this);
        this.ao = (int) Utils.m8026b(33.0f, (Context) this);
        this.ap = (int) Utils.m8026b(33.0f, (Context) this);
        this.aq = (int) Utils.m8026b(100.0f, (Context) this);
        this.f9058W = findViewById(R.id.backView);
        this.f9059X = findViewById(R.id.dragView);
        this.f9060Y = findViewById(R.id.msgDV);
        this.f9061Z = (ImageView) findViewById(R.id.rightArrow);
        this.progressBar1 = (ProgressBar) findViewById(R.id.progressBar1);
        this.tMsg1 = (TextView) findViewById(R.id.tMsg1);
        this.tMsg2 = (TextView) findViewById(R.id.tMsg2);
        this.mMyListView = (MyListView) findViewById(R.id.lv2);
        this.ae = (TextView) findViewById(R.id.listMsg);
        m13847G();
        m13845F();
        this.f9058W.setBackgroundColor(f9037O);
        this.f9060Y.setX((float) this.am);
        this.f9060Y.setY((float) this.an);
        this.f9060Y.setVisibility(View.VISIBLE);
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14465b();
        }
    }

    private void m13845F() {
        fh a = new ff(this).m14851a();
        if (a.m14878d()) {
            int e = a.m14879e();
            int dimensionPixelSize = this.f9056H.getDimensionPixelSize(R.dimen.main_ui_panel_height);
            GuliLog.tracePrintInfo(TAG, "SlidingPanel SystemBarH : " + e + ", OriginalPanelH : " + dimensionPixelSize);
            this.mSlidingUpPanelLayout.setPanelHeight(dimensionPixelSize - e);
            dimensionPixelSize = this.f9056H.getDimensionPixelSize(R.dimen.main_ui_dragview_height);
            GuliLog.tracePrintInfo(TAG, "SlidingPanel DragViewH : " + dimensionPixelSize);
            this.f9059X.setLayoutParams(new SlidingUpPanelLayout.LayoutParams(-1, dimensionPixelSize - e));
            this.ak = 1.3f;
            this.ao = (int) Utils.m8026b(55.0f, (Context) this);
        }
        if (C0804t.m8839d(this)) {
            this.mSlidingUpPanelLayout.setPanelHeight((int) C0804t.m8825a((Context) this, 250.0f));
        }
    }

    private void m13847G() {
        this.mLuaListAdapter = new LuaListAdapter(this, null);
        this.mMyListView.setAdapter(this.mLuaListAdapter);
        this.mMyListView.setParentPanelLayout(this.mSlidingUpPanelLayout);
        this.mSlidingUpPanelLayout.setListAdapter(this.mLuaListAdapter);
    }

    private void m13848H() {
        refreshListAndDetectBlank(false);
    }

    private void m13851I() {
        m13906e(false);
    }

    private void m13853J() {
        if (this.ax != null && this.ax.isStarted()) {
            this.ax.end();
        }
        float b = Utils.m8026b(36.0f, (Context) this);
        float[] fArr = new float[f9038P];
        fArr[f9037O] = 0.0f;
        fArr[f9032J] = 2900.0f;
        ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
        this.ax = ofFloat;
        ofFloat.setDuration((long) 1161117696);
        ofFloat.addListener(new bX(this, b));
        ofFloat.addUpdateListener(new bY(this, b));
        ofFloat.start();
    }

    class bY implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ float f9689a;
        final /* synthetic */ ScaleActivity f9690b;

        bY(ScaleActivity mainUIActivity, float f) {
            this.f9690b = mainUIActivity;
            this.f9689a = f;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            if (floatValue > BitmapDescriptorFactory.HUE_MAGENTA) {
                if (floatValue < 600.0f) {
                    this.f9690b.ae.setTranslationY((((floatValue - BitmapDescriptorFactory.HUE_MAGENTA) / BitmapDescriptorFactory.HUE_MAGENTA) * this.f9689a) - this.f9689a);
                } else if (floatValue >= 2600.0f) {
                    this.f9690b.ae.setTranslationY(((-(((floatValue - BitmapDescriptorFactory.HUE_MAGENTA) - BitmapDescriptorFactory.HUE_MAGENTA) - 2000.0f)) / BitmapDescriptorFactory.HUE_MAGENTA) * this.f9689a);
                }
            }
        }
    }

    class bX implements Animator.AnimatorListener {
        final /* synthetic */ float f9687a;
        final /* synthetic */ ScaleActivity f9688b;

        bX(ScaleActivity mainUIActivity, float f) {
            this.f9688b = mainUIActivity;
            this.f9687a = f;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f9688b.ae.setVisibility(View.GONE);
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f9688b.ae.setVisibility(View.VISIBLE);
            this.f9688b.ae.setTranslationY(-this.f9687a);
            this.f9688b.mLuaListAdapter.setFlagsToFalse();
        }
    }

    private void m13855K() {
        m13883a(1.27f);
    }

    private boolean m13857L() {
        if (!this.as) {
            return false;
        }
        if (this.at) {
            return true;
        }
        this.at = true;
        this.mHandler.sendEmptyMessageDelayed(f9034L, 60000);
        return true;
    }

    private boolean m13859M() {
        if (!this.as) {
            return false;
        }
        this.at = false;
        this.au = false;
        this.mHandler.removeMessages(f9034L);
        return true;
    }

    class bZ implements Animator.AnimatorListener {
        final /* synthetic */ ScaleActivity f9691a;

        bZ(ScaleActivity mainUIActivity) {
            this.f9691a = mainUIActivity;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f9691a.f9058W.setBackgroundColor(0);
            this.f9691a.f9060Y.setX((float) this.f9691a.am);
            this.f9691a.f9060Y.setY((float) this.f9691a.an);
            this.f9691a.f9060Y.setVisibility(View.VISIBLE);
            if (this.f9691a.mDynamicFragment != null) {
                this.f9691a.mDynamicFragment.m14465b();
            }
            Keeper.keepIsPlayEnterAnimation(Boolean.valueOf(false));
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f9691a.f9059X.setTranslationY(800.0f);
            this.f9691a.f9058W.setBackgroundResource(R.color.bg_mode_step);
            this.f9691a.f9060Y.setVisibility(View.GONE);
            this.f9691a.mLuaListAdapter.notifyDataSetChanged();
        }
    }

    class ViewAnimatorUpdateListener implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ ScaleActivity f9818a;

        ViewAnimatorUpdateListener(ScaleActivity mainUIActivity) {
            this.f9818a = mainUIActivity;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            this.f9818a.f9059X.setTranslationY(800.0f - ((Float) valueAnimator.getAnimatedValue()).floatValue());
        }
    }

    private void m13861N() {
        this.aw = ValueAnimator.ofFloat(new float[]{0.0f, 800.0f});
        this.aw.setDuration(500);
        this.aw.setInterpolator(new DecelerateInterpolator());
        this.aw.addListener(new bZ(this));
        this.aw.addUpdateListener(new ViewAnimatorUpdateListener(this));
        this.aw.start();
    }

    class cb implements Animator.AnimatorListener {
        final /* synthetic */ ScaleActivity f9819a;

        cb(ScaleActivity mainUIActivity) {
            this.f9819a = mainUIActivity;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f9819a.mSlidingUpPanelLayout.smoothSlideTo(1.0f, 0);
            this.f9819a.progressBar1.setVisibility(View.GONE);
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f9819a.f9060Y.setScaleX(1.0f);
            this.f9819a.f9060Y.setScaleY(1.0f);
            this.f9819a.f9060Y.setAlpha(1.0f);
            this.f9819a.f9060Y.setVisibility(View.VISIBLE);
        }
    }

    class cc implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ ScaleActivity f9820a;

        cc(ScaleActivity mainUIActivity) {
            this.f9820a = mainUIActivity;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f9820a.f9060Y.setScaleX(floatValue);
            this.f9820a.f9060Y.setScaleY(floatValue);
            this.f9820a.f9060Y.setAlpha(floatValue);
        }
    }


    private void m13863O() {
        ValueAnimator ofFloat = ValueAnimator.ofFloat(new float[]{1.0f, 0.0f});
        ofFloat.setDuration(300);
        ofFloat.addListener(new cb(this));
        ofFloat.addUpdateListener(new cc(this));
        ofFloat.start();
    }

    private void m13865P() {
        if (this.ay != null) {
            if (!this.ay.isStarted()) {
                this.ay.start();
            } else {
                return;
            }
        }
        this.ay = ValueAnimator.ofFloat(new float[]{0.0f, 1.0f});
        this.ay.setDuration(100);
        this.ay.addListener(new cd(this));
        this.ay.addUpdateListener(new ce(this));
        this.ay.start();
    }

    class cd implements Animator.AnimatorListener {
        final /* synthetic */ ScaleActivity f9821a;

        cd(ScaleActivity mainUIActivity) {
            this.f9821a = mainUIActivity;
        }

        public void onAnimationCancel(Animator animator) {
        }

        public void onAnimationEnd(Animator animator) {
            this.f9821a.tMsg1.setScaleX(1.0f);
            this.f9821a.tMsg1.setScaleY(1.0f);
            this.f9821a.tMsg2.setScaleX(1.0f);
            this.f9821a.tMsg2.setScaleY(1.0f);
            this.f9821a.tMsg1.setAlpha(1.0f);
            this.f9821a.tMsg2.setAlpha(1.0f);
            this.f9821a.f9061Z.setRotation(BitmapDescriptorFactory.HUE_CYAN);
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationStart(Animator animator) {
            this.f9821a.f9060Y.setScaleX(1.0f);
            this.f9821a.f9060Y.setScaleY(1.0f);
            this.f9821a.f9060Y.setAlpha(1.0f);
            this.f9821a.tMsg1.setScaleX(0.5f);
            this.f9821a.tMsg1.setScaleY(0.5f);
            this.f9821a.tMsg2.setScaleX(0.5f);
            this.f9821a.tMsg2.setScaleY(0.5f);
            this.f9821a.tMsg1.setAlpha(0.5f);
            this.f9821a.tMsg2.setAlpha(0.5f);
            this.f9821a.f9061Z.setRotation(0.0f);
            this.f9821a.tMsg1.setText(R.string.dynamic_pull_release_to_sync);
            this.f9821a.tMsg2.setText(Utils.m7976a(this.f9821a, (int) R.string.dynamic_pull_last_sync_time));
        }
    }

    private void m13867Q() {
        if (m13871S() || m13869R()) {
            setLocale();
            set24HourFormat();
            refreshUI();
            return;
        }
        LuaEvent.getInstance(this).setDefaultMsgs();
        m13848H();
    }

    class ce implements ValueAnimator.AnimatorUpdateListener {
        final /* synthetic */ ScaleActivity f9822a;

        ce(ScaleActivity mainUIActivity) {
            this.f9822a = mainUIActivity;
        }

        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float floatValue = 0.5f + (((Float) valueAnimator.getAnimatedValue()).floatValue() * 0.5f);
            float floatValue2 = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            this.f9822a.tMsg1.setScaleX(floatValue);
            this.f9822a.tMsg1.setScaleY(floatValue);
            this.f9822a.tMsg2.setScaleX(floatValue);
            this.f9822a.tMsg2.setScaleY(floatValue);
            this.f9822a.tMsg1.setAlpha(floatValue);
            this.f9822a.tMsg2.setAlpha(floatValue);
            this.f9822a.f9061Z.setRotation(360.0f - (floatValue2 * BitmapDescriptorFactory.HUE_CYAN));
        }
    }

    private boolean m13869R() {
        return Keeper.read24HourFormat() != DateFormat.is24HourFormat(this);
    }

    private boolean m13871S() {
        String readLocaleStr = Keeper.readLocaleStr();
        if (C3657a.f18328f.equals(readLocaleStr)) {
            readLocaleStr = Keeper.keepLocaleStr();
        }
        if (readLocaleStr.equals(Locale.getDefault().toString())) {
            return false;
        }
        GuliLog.tracePrintInfo(TAG, "set locale when changed");
        return true;
    }

    private void setLocale() { // m13873T
        Keeper.keepLocaleStr();
        LuaEvent.getInstance(this).setLocale(Locale.getDefault().toString());
    }

    private void set24HourFormat() { // m13875U
        boolean is24HourFormat = DateFormat.is24HourFormat(this);
        LuaEvent.getInstance(this).set24HourFormat(is24HourFormat);
        Keeper.keep24HourFormat(is24HourFormat);
    }

    private void refreshUI() { // m13876V
        GuliLog.tracePrintInfo(TAG, "refreshUI");
        m13879Y();
        clearLuaDb(true);
//        m13877W();
        m13956h();
    }

//    private void m13877W() {
//        if (this.f9078w != null && this.f9077v != null) {
//            this.dynamicSubtitle.setText(C3657a.f18328f);
//            this.f9078w.cleanSavedWeatherInfo();
//            this.f9077v.m12144d();
//            this.f9077v.m12142b(C1429e.f7291b);
//        }
//    }

    private void m13878X() {
        LuaEvent.getInstance(this).setLocale(Locale.getDefault().toString());
        String luaVersion = LuaEvent.getInstance(this).getLuaVersion();
        String readLatestDBLuaVersion = Keeper.readLatestDBLuaVersion();
        GuliLog.tracePrintInfo(TAG, "newVersion = " + luaVersion + ", oldVersion = " + readLatestDBLuaVersion);
        if (C4220a.cf.equals(readLatestDBLuaVersion) && luaVersion != null) {
            Keeper.keepLatestDBLuaVersion(luaVersion);
        }
        if (luaVersion != null && luaVersion.compareTo(readLatestDBLuaVersion) > 0) {
            Keeper.keepLatestDBLuaVersion(luaVersion);
            LuaEvent.getInstance(this).resetLuaState();
            clearLuaDb(true);
            GuliLog.tracePrintInfo(TAG, "Update LUA to version: " + luaVersion);
        }
    }

    private void m13879Y() {
        if (!this.f9054F.f4199i.f4229a.booleanValue()) {
            return;
        }
//        if (GameManager.NEW_GAME.equals(LuaEvent.getInstance(this).getGameInfo())) {
//            this.f9079x.processGameEvent(this.mContext, C3657a.f18328f);
//        } else {
//            this.f9079x.processGameEvent(this.mContext, GameManager.STR_GAME_CLEAR_BANNER);
//        }
    }

//    private void m13880Z() {
//        GuliLog.tracePrintInfo(TAG, "updateDynamicListByWeather, aqi level = " + this.aA + ", last aqi = " + this.aB);
//        LuaEvent.getInstance(this).setLocale(Locale.getDefault().toString());
//        if (this.aA < f9047e) {
//            DynamicManager.getInstance().m7905a(this.mContext, this.aA);
//        } else if (this.aA != this.aB) {
//            DynamicManager.getInstance().m7905a(this.mContext, this.aA);
//            this.aB = this.aA;
//        }
//        m13848H();
//    }

    private void m13883a(float f) {
        if (this.mSlidingUpPanelLayout == null) {
            GuliLog.tracePrintError(TAG, "not init layout");
            return;
        }
        GuliLog.tracePrintInfo(TAG, "showPullDownMsgs, mIsPulledDown = " + this.aj);
        this.aj = true;
        this.f9060Y.setScaleX(1.0f);
        this.f9060Y.setScaleY(1.0f);
        this.f9060Y.setAlpha(1.0f);
        this.f9060Y.setTranslationY((float) this.an);
        this.ae.setVisibility(View.GONE);
        this.mSlidingUpPanelLayout.smoothSlideTo(f, f9037O);
    }

//    private void m13884a(Context context, C1461h c1461h) {
//        if (c1461h.m12285f()) {
//            C0668a.m8126a((Context) this, C0668a.eN);
//        }
//        if (c1461h.m12284e()) {
//            C0668a.m8126a((Context) this, C0668a.eO);
//        }
//        for (C1454a c1454a : c1461h.m12280c()) {
//            C0668a.m8128a(context, C0668a.eP, c1454a.f7385a + "_" + (c1454a.f7386b ? C0668a.fG : C0668a.fH));
//        }
//    }

    private void m13885a(Intent intent) {
        if (intent != null) {
            if (!(!intent.getBooleanExtra(Constant.aL, false) || Utils.m8088m(this) || DeviceSource.hasBindDevice())) {
                if (Config.m8876h().f4202l.f4259a.booleanValue()) {
                    intent.setClass(this, SelectDevicesActivity.class);
                } else {
                    intent.setClass(this, SearchSingleBraceletActivity.class);
                }
                startActivity(intent);
            }
            String stringExtra = intent.getStringExtra(Constant.aN);
            GuliLog.tracePrintInfo(TAG, "open page extra = " + stringExtra);
            if (Constant.cb.equals(stringExtra)) {
                intent.setClass(this, SettingAboutActivity.class);
                Bundle bundle = new Bundle();
                bundle.putBoolean(Constant.aP, true);
                intent.putExtra(Constant.aN, bundle);
                startActivity(intent);
            }
            if (intent.getIntExtra(C4220a.bJ, f9037O) == f9032J) {
                startActivity(new Intent(this, GuliHardwareSettingActivity.class));
            }
        }
    }

    private void m13890a(HwConnStatus hwConnStatus) {
        boolean z = hwConnStatus.m25403f() || (!hwConnStatus.m25408k() && this.av);
        this.av = z;
        if (this.av) {
            ab();
        } else if (hwConnStatus.m25408k()) {
            ac();
        } else if (hwConnStatus.m25402e()) {
            aa();
        } else {
            m13857L();
            if (!this.au) {
                aa();
            }
        }
    }

    private void m13891a(String str, int i) {
        if (i >= 0) {
            this.ae.setText(str);
            if (i > 0) {
                m13853J();
                this.ae.setOnClickListener(null);
                this.ae.setBackgroundColor(0xE059A712);
                return;
            }
            this.ae.setVisibility(View.VISIBLE);
            this.ae.setOnClickListener(null);
            this.ae.setBackgroundColor(0xE0E17534);
        }
    }

    private void m13892a(String str, String str2) {
        m13893a(str, str2, f9032J, 0.0f);
    }

    private void m13893a(String str, String str2, int i, float f) {
        this.ai = i;
        GuliLog.tracePrintInfo(TAG, "enter:" + str + " " + str2 + " type:" + i + "offset: " + f);
        this.tMsg1.setText(str);
        this.tMsg2.setText(str2);
        if (i == 0) {
            float f2 = (float) (this.an - this.ao);
            this.f9060Y.setTranslationY((((f - 1.0f) / (this.ak - 1.0f)) * ((float) this.ap)) + f2);
            if (f < this.ak) {
                this.f9060Y.setScaleX(1.0f);
                this.f9060Y.setScaleY(1.0f);
                this.f9060Y.setAlpha(1.0f);
            }
            this.f9061Z.setVisibility(View.VISIBLE);
            this.f9061Z.setImageResource(R.drawable.pulldown);
            this.progressBar1.setVisibility(View.GONE);
            this.tMsg1.setTextColor(0xff555555);
            this.tMsg2.setTextColor(0xff9f9f9f);
        } else if (i == f9038P || i == f9039Q) {
            LuaEvent.getInstance(this.mContext).setConnectStatus(false);
            this.aj = false;
            this.tMsg1.setTextColor(0xffdf4c12);
            this.tMsg2.setTextColor(0xFFEA9F8D);
            this.f9061Z.setVisibility(View.VISIBLE);
            this.f9061Z.setImageResource(R.drawable.pulldown2);
            this.progressBar1.setVisibility(View.GONE);
            m13855K();
        } else {
            this.tMsg1.setTextColor(0xff555555);
            this.tMsg2.setTextColor(0xff9f9f9f);
            m13855K();
            this.f9061Z.setVisibility(View.INVISIBLE);
            this.progressBar1.setVisibility(View.VISIBLE);
        }
    }

    private void aa() {
        m13903e((int) f9032J);
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14463a(Boolean.valueOf(true));
        }
    }

    private void ab() {
        m13903e((int) f9037O);
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14463a(Boolean.valueOf(true));
        }
    }

    private void ac() {
        LuaEvent.getInstance(this).setConnectStatus(true);
        refreshListAndDetectBlank(true);
        m13859M();
        this.ae.setVisibility(View.GONE);
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14463a(Boolean.valueOf(false));
        }
        this.mHandler.sendEmptyMessageDelayed(f9036N, 1000);
    }

    private void ad() {
        ae();
        af();
    }

    private void ae() {
        CharSequence readPushIntentUri = Keeper.readPushIntentUri();
        if (!TextUtils.isEmpty(readPushIntentUri)) {
            try {
                startActivity(Intent.parseUri((String)readPushIntentUri, f9037O));
            } catch (URISyntaxException e) {
                e.printStackTrace();
            } catch (RuntimeException e2) {
                e2.printStackTrace();
            }
            Keeper.keepPushIntentUri(C3657a.f18328f);
        }
    }

    private void af() {
        String readLuaItem = Keeper.readLuaItem();
        if (TextUtils.isEmpty(readLuaItem)) {
            GuliLog.tracePrintInfo(TAG, "luaItem is empty");
            return;
        }
        LuaItem luaItem;
        try {
            luaItem = (LuaItem) Utils.m8049c().fromJson(readLuaItem, LuaItem.class);
        } catch (Exception e) {
            luaItem = null;
        }
        if (luaItem != null) {
            LuaEvent.getInstance(this).showLuaItem(luaItem);
            m13848H();
            Keeper.keepLuaItem(C3657a.f18328f);
        }
    }

    private void getPersonWeightValue() {
        PersonInfo readPersonInfo = Keeper.readPersonInfo();
        WeightInfo a = WeightInfoManager.getInstance().m15743a(-1, (int) f9037O);
        if (a == null) {
            GuliLog.tracePrintInfo("PERSON_WEIGHT", "info is null ");
        } else if (a.weight == readPersonInfo.weight) {
            GuliLog.tracePrintInfo("PERSON_WEIGHT", "person info not updated");
        } else {
            GuliLog.tracePrintInfo("PERSON_WEIGHT", "upload person info weight " + a.weight);
            readPersonInfo.weight = a.weight;
            readPersonInfo.setNeedSyncServer(f9038P);
            Keeper.keepPersonInfo(readPersonInfo);
        }
    }

    private void m13896b(HwConnStatus hwConnStatus) {
        if (hwConnStatus.m25402e()) {
            GuliLog.tracePrintInfo(TAG, "Ble Status : Is searching!!");
            aa();
        } else if (hwConnStatus.m25403f()) {
            ab();
        } else if (hwConnStatus.m25408k()) {
            ac();
        } else {
            m13857L();
            if (!this.au) {
                aa();
            }
        }
    }

    private void refreshListAndDetectBlank(boolean z) {
        GuliLog.tracePrintInfo(TAG, "refreshListAndDetectBlank forceRefresh= " + z);
        if (this.mLuaListAdapter == null) {
            GuliLog.tracePrintInfo(TAG, "UI is not ready!");
            return;
        }
        this.mLuaListAdapter.refreshList();
        int newItemCount = this.mLuaListAdapter.getNewItemCount();
        GuliLog.tracePrintInfo(TAG, "newItemCount:" + newItemCount);
        if (!z && newItemCount > 0 && DeviceSource.hasBindDevice()) {
            Resources resources = this.f9056H;
            Object[] objArr = new Object[f9032J];
            objArr[f9037O] = Integer.valueOf(newItemCount);
            // update the dao list
            m13891a(resources.getQuantityString(R.plurals.numberOfPullUpdateReport, newItemCount, objArr), (int) f9038P);
        }
    }

    private void m13903e(int i) {
        String str = null;
        String string = null;
        int r = DataManager.m12179a().m12239r();
        if (r == f9039Q) {
            string = getString(R.string.devices_shoes_label);
        } else {
            string = r == 0 ? getString(R.string.devices_miband_label) : null;
        }
        Object[] objArr;
        if (i == 0) {
            String format;
            Object[] objArr2;
            if (r == f9039Q) {
                str = getString(R.string.shoes_home_tips_connect_failed);
                objArr = new Object[f9032J];
                objArr[f9037O] = string;
                format = String.format(str, objArr);
                str = getString(R.string.shoes_alert_body_connect_failed);
                objArr2 = new Object[f9032J];
                objArr2[f9037O] = string;
                str = String.format(str, objArr2);
            } else if (r == 0) {
                str = getString(R.string.dynamic_pull_connect_failed);
                objArr = new Object[f9032J];
                objArr[f9037O] = string;
                format = String.format(str, objArr);
                str = getString(R.string.dynamic_pull_connect_failed_hint);
                objArr2 = new Object[f9032J];
                objArr2[f9037O] = string;
                str = String.format(str, objArr2);
            } else {
                format = null;
            }
            m13893a(format, str, f9038P, 0.0f);
        } else if (i == f9032J) {
            str = getString(R.string.dynamic_pull_connecting_bracelet);
            objArr = new Object[f9032J];
            objArr[f9037O] = string;
            m13892a(String.format(str, objArr), String.format(getString(R.string.dynamic_pull_sync_after_connected), new Object[f9037O]));
        }
    }

    private void m13906e(boolean z) {
        if (!this.aj && !z) {
            GuliLog.tracePrintInfo(TAG, "not pulled down yet");
        } else if (this.mSlidingUpPanelLayout == null) {
            GuliLog.tracePrintError(TAG, "not init layout");
        } else {
            this.aj = false;
            m13863O();
            m13848H();
        }
    }

    private void m13908f(boolean z) {
        this.as = z;
    }

    private void clearLuaDb(boolean z) { // m13911g
        GuliLog.tracePrintInfo(TAG, "Clear lua db...............");
        DaoManager.getInstance().getLuaListDao().deleteAll();
        DaoManager.getInstance().getLuaZipFileDao().deleteAll();
        new Thread(new cf(this)).start();
        LuaEvent.getInstance(this).setCurLocale();
        LuaEvent.getInstance(this).setDefaultMsgs(Boolean.valueOf(z));
        refreshListAndDetectBlank(z);
    }

    class cf implements Runnable {
        final /* synthetic */ ScaleActivity f9823a;

        cf(ScaleActivity mainUIActivity) {
            this.f9823a = mainUIActivity;
        }

        public void run() {
//            DynamicManager.getInstance().analysisDynamic(this.f9823a.mContext, true);
            this.f9823a.runOnUiThread(new cg(this));
        }
    }

    class cg implements Runnable {
        final /* synthetic */ cf f9824a;

        cg(cf cfVar) {
            this.f9824a = cfVar;
        }

        public void run() {
            this.f9824a.f9823a.updateUI(true);
        }
    }

    private void m13919m() {
    }

//    private void m13920n() {
//        if (this.f9054F.f4207q.f4231a.booleanValue()) {
//            this.f9049A = MedalManager.m11452a();
//            this.f9049A.m11472a(getApplicationContext());
//        }
//    }

    private void m13923o() {
    }

    private void m13925p() {
        PersonInfo readPersonInfo = Keeper.readPersonInfo();
        if (readPersonInfo.nickname == null || !readPersonInfo.nickname.isEmpty()) {
            GuliLog.tracePrintInfo(TAG, "nick name is not null " + readPersonInfo.nickname);
            return;
        }
        GuliLog.tracePrintInfo(TAG, "nick name is empty and give it a new nickname " + C0886a.m9071f(this.mContext).uid);
        readPersonInfo.nickname = C0886a.m9071f(this.mContext).uid + C3657a.f18328f;
        Keeper.keepPersonInfo(readPersonInfo);
    }

    private void m13927q() {
        this.mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
        this.mSlidingUpPanelLayout.setOverlayed(true);
        this.mSlidingUpPanelLayout.setEnableDragViewTouchEvents(true);
        this.mSlidingUpPanelLayout.setPanelSlideListener(this.mPanelSlideListener);
    }

    class ch extends BroadcastReceiver {
        final /* synthetic */ ScaleActivity f9825a;

        ch(ScaleActivity mainUIActivity) {
            this.f9825a = mainUIActivity;
        }

        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            GuliLog.tracePrintInfo("ScaleActivity", "action : " + action);
            if ("android.intent.action.DOWNLOAD_COMPLETE".equals(action)) {
//                GuliLog.tracePrintInfo(MiPushMessageReceiver.PUSH_TYPE_INTENT, C3657a.f18328f + intent.getLongExtra("extra_download_id", 0));
//                Utils.m8038b(this.f9825a);
            } else if (C4220a.bM.equals(action) || C4220a.bN.equals(action) || Constant.bZ.equals(action)) {
                this.f9825a.m13931s();
                Intent intent1 = new Intent(context, GuliHardwareSettingActivity.class);
                intent1.setFlags(67108864);
//                if (C4220a.bN.equals(action)) {
//                    intent1.setClass(context, AlarmActivity.class);
//                } else if (Constant.bZ.equals(action)) {
//                    intent1.putExtra(Utils.f3493a, Utils.f3495c);
//                }
                context.startActivity(intent);
            } else if (Constant.aY.equals(action)) {
//                DynamicManager.getInstance().m7908c(this.f9825a.mContext);
            } else if (Constant.bV.equals(action)) {
//                C0668a.m8126a(this.f9825a, C0708b.aX);
//                this.f9825a.m13931s();
//                r0 = new Intent(context, MessageActivity.class);
//                r0.setFlags(67108864);
//                context.startActivity(r0);
            } else if (Constant.bW.equals(action)) {
//                this.f9825a.m13931s();
//                r1 = new Intent("android.intent.action.VIEW", Uri.parse(intent.getStringExtra(C1612j.f8079e)));
//                r1.setFlags(67108864);
//                context.startActivity(r1);
            } else if (Constant.bX.equals(action)) {
//                this.f9825a.m13931s();
//                r0 = WebActivity.buildIntent(context, (Partner) intent.getExtras().getSerializable("partner"));
//                r0.setFlags(67108864);
//                context.startActivity(r0);
            }
        }
    }

    private void m13928r() {
        this.mBroadcastReceiver = new ch(this);
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.intent.action.DOWNLOAD_COMPLETE");
        intentFilter.addAction(C4220a.bM);
        intentFilter.addAction(Constant.bZ);
        intentFilter.addAction(C4220a.bN);
        intentFilter.addAction(Constant.aY);
        intentFilter.addAction(Constant.bV);
        intentFilter.addAction(Constant.bW);
        intentFilter.addAction(Constant.bX);
        registerReceiver(this.mBroadcastReceiver, intentFilter);
    }

    private void m13931s() {
        int i;
        ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(50);
        if (runningTasks != null) {
            i = -1;
            for (ActivityManager.RunningTaskInfo runningTaskInfo : runningTasks) {
                ComponentName componentName = runningTaskInfo.baseActivity;
                GuliLog.tracePrintInfo(TAG, "recent activity:" + componentName.getClassName());
                i = componentName.getClassName().contains("cn.com.smartdevices.bracelet.ui.ScaleActivity") ? runningTaskInfo.id : i;
            }
        } else {
            i = -1;
        }
        if (i != -1) {
            GuliLog.tracePrintInfo(TAG, "move mainUI activity to front");
            activityManager.moveTaskToFront(i, f9037O);
        }
    }

    class cs extends Handler {
        final /* synthetic */ ScaleActivity f9837a;

        cs(ScaleActivity mainUIActivity) {
            this.f9837a = mainUIActivity;
        }

        public void handleMessage(Message message) {
            switch (message.what) {
                case 272 /*272*/:
                    GuliLog.tracePrintInfo("ScaleActivity", "receive the msg reconnect timeout");
                    this.f9837a.m13903e(0);
                    this.f9837a.refreshListAndDetectBlank(true);
                    this.f9837a.au = true;
                    break;
                case 273 /*273*/:
                    HwConnStatus k;
                    if (DeviceSource.hasBindBracelet()) {
                        k = XMBLEManager.m25166k();
                        HwSyncDataStatus l = this.f9837a.mHwSyncDataStatus;
                        if (k.m25399b().m25104c() && l.m25418e()) {
                            this.f9837a.onEvent(l);
                        } else if (l.m25421h().m25104c() && !k.m25401d()) {
                            this.f9837a.onEvent(k);
                        }
                    } else if (DeviceSource.hasBindShoesDevice()) {
                        HwSyncDataStatus l2 = this.f9837a.mHwSyncDataStatus;
                        if (C3843c.SHOES.equals(l2.m25421h()) && l2.m25418e()) {
                            this.f9837a.onEvent(l2);
                            return;
                        }
                        k = this.f9837a.mHwConnStatus;
                        if (C3843c.SHOES.equals(k.m25399b()) && !k.m25401d()) {
                            this.f9837a.onEvent(k);
                        }
                    }
                    break;
                case 274:
                    this.f9837a.m13851I();
                    break;
                case ScaleActivity.f9045c /*520*/:
                    this.f9837a.f9052D = -1;
                    break;
                default:
                    break;
            }
        }
    }

    private void m13933t() {
        this.mHandler = new cs(this);
    }

    class ct implements View.OnClickListener {
        final /* synthetic */ ScaleActivity f9838a;

        ct(ScaleActivity mainUIActivity) {
            this.f9838a = mainUIActivity;
        }

       public void onClick(View view) {
// TBD           this.f9838a.f9077v.m12144d();
//            this.f9838a.f9077v.m12143c();
        }
    }

    private void m13935u() {
        this.headerNavLeft = findViewById(R.id.header_nav_left);
        this.headerNavLeft.setOnClickListener(this);
        this.headerNavRight = findViewById(R.id.header_nav_right);
        this.headerNavRight.setOnClickListener(this);
        this.dynamicTitle = (TextView) findViewById(R.id.dynamic_title);
        this.dynamicSubtitle = (TextView) findViewById(R.id.dynamic_subtitle);
        this.dynamicTitle.setOnClickListener(new ct(this));
        if (C0804t.m8835a()) {
            this.dynamicTitle.setTextSize(14.0f);
        }
    }

    private void m13937v() {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
        this.mDynamicFragment = (DynamicFragment) Fragment.instantiate(this, DynamicFragment.class.getName());
        beginTransaction.add(R.id.container, this.mDynamicFragment, "DynamicFragment");
        beginTransaction.commit();
        fragmentManager.executePendingTransactions();
        if (DeviceSource.hasBindWeight() && !DeviceSource.hasBindBracelet()) {
            this.mDynamicFragment.m14466b((int) PersonInfo.INCOMING_CALL_DISABLE_BIT);
        }
    }

    private void m13939w() {
        m13878X();
        m13834A();
    }

//    private void m13941x() {
//        if (this.f9054F.f4194d.f4252a.booleanValue()) {
//            this.f9076u = C1492h.m12327a(getApplicationContext());
//        }
//        this.f9077v = C1429e.m12138a(getApplicationContext());
//        this.f9078w = WeatherManager.getManager(getApplicationContext());
//        this.f9078w.registerLocationChanged();
//        this.f9078w.registerWeatherListener(new cu(this));
//        this.f9077v.m12142b(C1429e.f7291b);
//        if (this.f9054F.f4193c.f4248d.booleanValue()) {
//            QQLogin.getInstance(getApplicationContext());
//            QQHealth.getInstance(getApplicationContext());
//        }
//        this.f9079x = new GameManager();
//        if (TextUtils.isEmpty(Keeper.readLazyDays())) {
//            Utils.m8052c(this.mContext);
//        }
//        this.f9080y = new PartnerDataManager(this);
//        this.f9080y.loadAvailableServiceList(true);
//        this.f9080y.loadHomeMessageList();
//        m13884a((Context) this, C1461h.m12263a((Context) this));
//    }
//
//    private void m13943y() {
//        if (C1351h.m11768a()) {
//            findViewById(R.id.header_nav_right_new_sign).setVisibility(f9037O);
//        } else {
//            findViewById(R.id.header_nav_right_new_sign).setVisibility(View.GONE);
//        }
//    }
//
    private void m13944z() {
        getPersonWeightValue();
        m13867Q();
        ad();
//        m13943y();
//        QQLogin instance = QQLogin.getInstance();
//        if (instance != null && instance.isLoginValid()) {
//            C0668a.m8126a((Context) this, C0668a.eM);
//        }
        if (Config.m8876h().f4202l.f4259a.booleanValue()) {
            WeightUtil.m15712b(this.mContext);
        }
//        if (Config.m8876h().f4209s.f4230a.booleanValue()) {
//            new Thread(new cy(this)).start();
//        }
//        C1961v.m15506a().m15517e(getApplicationContext());
    }

    protected void onDeviceBonded(int i) { // m13946a
        super.onDeviceBonded(i);
        GuliLog.tracePrintInfo(TAG, "onDeviceBonded deviceType " + i);
        if (i == 0 || i == f9032J || i == f9039Q) {
            m13851I();
            if (this.mDynamicFragment != null) {
                this.mDynamicFragment.m14468d();
            }
        }
        if (i == f9032J && this.mDynamicFragment != null) {
            this.mDynamicFragment.m14466b((int) PersonInfo.INCOMING_CALL_DISABLE_BIT);
        }
    }

    protected void m13658b (int i) { // m13947b
        super.m13658b(i);
        if (i == 0 || i == f9032J || i == f9039Q) {
            m13851I();
            if (this.mDynamicFragment != null) {
                this.mDynamicFragment.m14468d();
            }
        }
        if (i == f9032J && this.mDynamicFragment != null) {
            this.mDynamicFragment.m14466b((int) f9032J);
        }
    }

    protected void updateUI(boolean z) { // m13948b
        GuliLog.tracePrintInfo(TAG, "updateUI.............");
        refreshListAndDetectBlank(z);
    }

    protected void m13949c() {
        m13859M();
        LuaEvent.getInstance(this).setDefaultMsgs();
        this.mSlidingUpPanelLayout.setPullDownEnabled(false);
        m13851I();
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14469e();
        }
        this.mHwConnStatus = new HwConnStatus();
    }

    public void m13950c(int i) {
        int i2 = R.string.dynamic_title_weight_unbind;
        int i3 = R.string.dynamic_title_bracelet_unbind;
        if (!this.f9071p || i == PersonInfo.INCOMING_CALL_DISABLE_BIT) {
            switch (i) {
                case f9032J /*1*/:
                    if (DeviceSource.hasBindBracelet() || DeviceSource.hasBindShoesDevice()) {
                        i3 = R.string.dynamic_title_step;
                    }
                    updateTitle(i3);
                    return;
                case C4220a.bp /*16*/:
                    if (DeviceSource.hasBindBracelet()) {
                        i3 = R.string.dynamic_title_sleep;
                    }
                    updateTitle(i3);
                    return;
                case PersonInfo.INCOMING_CALL_DISABLE_BIT /*256*/:
                    if (this.f9055G) {
                        updateTitle(DeviceSource.hasBindWeight() ? R.string.dynamic_title_weight_not_nearby : R.string.dynamic_title_weight_unbind);
                        return;
                    }
                    if (DeviceSource.hasBindWeight()) {
                        i2 = R.string.dynamic_title_weight;
                    }
                    updateTitle(i2);
                    return;
                default:
                    return;
            }
        }
        m13836B();
    }

    protected void onSensorHub() { // m13951d
        super.onSensorHub();
        GuliLog.m12370d(TAG, "onSensorHub");
        m13859M();
        this.mHwConnStatus = new HwConnStatus();
    }

    public void m13952d(int i) {
        ((ImageView) this.headerNavLeft.findViewById(R.id.btn)).setImageResource(i);
    }

    protected void onSensorHubBinded() { // m13953e
        super.onSensorHubBinded();
        GuliLog.m12370d(TAG, "onSensorHubBinded");
        LuaEvent.getInstance(this).setDefaultMsgs();
        m13851I();
        m13956h();
        this.mHwConnStatus = new HwConnStatus();
        if (this.mDynamicFragment != null) {
            this.mDynamicFragment.m14468d();
        }
    }

    protected void onWeightScanTimeout () {// m13954f
        super.onWeightScanTimeout();
        this.f9055G = true;
        m13956h();
    }

    protected void onWeightFound() { // m13955g
        super.onWeightFound();
        if (this.f9055G) {
            this.f9055G = false;
            m13956h();
        }
    }

    public void m13956h() {
        m13950c(ChartData.m8731a().m8817u());
    }

    protected void m13957i() {
        Keeper.setEnterAppTrace(f9032J);
        moveTaskToBack(true);
    }

    class cA implements Runnable {
        final /* synthetic */ View f9735a;
        final /* synthetic */ int f9736b;
        final /* synthetic */ ScaleActivity f9737c;

        cA(ScaleActivity mainUIActivity, View view, int i) {
            this.f9737c = mainUIActivity;
            this.f9735a = view;
            this.f9736b = i;
        }

        public void run() {
            this.f9737c.dynamicTitle.setVisibility(View.GONE);
            this.f9737c.f9058W.setBackgroundResource(R.color.window_bg);
            this.f9737c.f9058W.buildDrawingCache();
            Bitmap drawingCache = this.f9737c.f9058W.getDrawingCache();
            this.f9737c.headerNavLeft.setVisibility(View.VISIBLE);
            this.f9737c.headerNavRight.setVisibility(View.VISIBLE);
            this.f9737c.f9060Y.setVisibility(View.VISIBLE);
            this.f9737c.dynamicTitle.setVisibility(View.VISIBLE);
            this.f9735a.setVisibility(this.f9736b);
            String str = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + C4220a.cb;
//            if (Utils.m8021a(str, drawingCache)) {
//                this.f9737c.f9058W.setBackgroundResource(0);
//                this.f9737c.f9058W.destroyDrawingCache();
//                Intent intent = new Intent();
//                intent.setClass(this.f9737c, ShareListDelegateActivity.class);
//                Object reportData = new ReportData();
//                reportData.setType(ShareListDelegateActivity.SHARE_TYPE_MAIN_UI_SHARE);
//                reportData.picture_url = str;
//                intent.putExtra(ShareListDelegateActivity.REF_REPORT_DATA, Utils.m8049c().toJson(reportData));
//                this.f9737c.startActivity(intent);
//            }
        }
    }
    public void m13958j() {
        int i;
        if (this.ag) {
            i = f9037O;
        } else {
            i = C4220a.aA;
            this.mSlidingUpPanelLayout.smoothSlideTo(1.0f, f9037O);
        }
        this.headerNavLeft.setVisibility(View.INVISIBLE);
        this.headerNavRight.setVisibility(View.INVISIBLE);
        this.f9060Y.setVisibility(View.INVISIBLE);
        View c = this.mDynamicFragment.m14467c();
        int visibility = c.getVisibility();
        c.setVisibility(View.INVISIBLE);
        this.mSlidingUpPanelLayout.postDelayed(new cA(this, c, visibility), (long) i);
    }

    public void m13959k() {
        LayoutAnimationController layoutAnimationController = new LayoutAnimationController(AnimationUtils.loadAnimation(this, R.anim.list_fadein));
        layoutAnimationController.setOrder(f9037O);
        layoutAnimationController.setInterpolator(new DecelerateInterpolator());
        layoutAnimationController.setDelay(0.5f);
        this.mMyListView.setLayoutAnimation(layoutAnimationController);
    }

    class cn implements Runnable {
        final /* synthetic */ cm f9832a;

        cn(cm cmVar) {
            this.f9832a = cmVar;
        }

        public void run() {
            this.f9832a.f9831a.updateUI(false);
        }
    }

    class cm implements Runnable {
        final /* synthetic */ ScaleActivity f9831a;

        cm(ScaleActivity mainUIActivity) {
            this.f9831a = mainUIActivity;
        }

        public void run() {
            DynamicManager.getInstance().m7904a(this.f9831a.mContext);
            this.f9831a.runOnUiThread(new cn(this));
        }
    }

    public void m13960l() {
        new Thread(new cm(this)).start();
    }

    public void onBackPressed() {
        long currentTimeMillis = System.currentTimeMillis();
        if (this.f9052D == -1) {
            C3247b.m22928a((Context) this, (int) R.string.app_exit_press_again, (int) f9037O).show();
            this.f9052D = currentTimeMillis;
            this.mHandler.sendEmptyMessageDelayed(f9045c, 2000);
        } else if (currentTimeMillis - this.f9052D < 2000) {
            this.f9052D = -1;
            m13957i();
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.header_nav_left:
                onStatisticActivity(); // m13838C
                break;
            case R.id.header_nav_right:
                onMainMenuFragment(); // m13840D
                break;
            default:
                break;
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        GuliLog.tracePrintInfo(TAG, "onConfigurationChanged");
        setLocale();
        refreshUI();
    }

    class bV implements Runnable {
        final /* synthetic */ bT f9685a;

        bV(bT bTVar) {
            this.f9685a = bTVar;
        }

        public void run() {
            Config.m8859a(this.f9685a.f9683a.getApplicationContext());
        }
    }

    class bU implements Runnable {
        final /* synthetic */ bT f9684a;

        bU(bT bTVar) {
            this.f9684a = bTVar;
        }

        public void run() {
//            this.f9684a.f9683a.m13920n();
            this.f9684a.f9683a.m13925p();
            this.f9684a.f9683a.m13923o();
            this.f9684a.f9683a.m13937v();
            this.f9684a.f9683a.m13843E();
            this.f9684a.f9683a.m13939w();
//            this.f9684a.f9683a.m13941x();
            this.f9684a.f9683a.m13919m();
        }
    }

    class bT implements Runnable {
        final /* synthetic */ ScaleActivity f9683a;

        bT(ScaleActivity mainUIActivity) {
            this.f9683a = mainUIActivity;
        }

        public void run() {
            this.f9683a.mHandler.post(new bU(this));
            this.f9683a.mHandler.postDelayed(new bV(this), 5000);
        }
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        PersonInfo personInfo = Keeper.readPersonInfo();
        Intent intent;
        
        this.mContext = this;
        this.f9056H = getResources();
        setContentView((int) R.layout.activity_main);
        disableAutoApplyStatusBarTint();
        if (DeviceSource.hasBindBracelet() || DeviceSource.hasBindShoesDevice()) {
            findViewById(R.id.backView).setBackgroundColor(this.f9056H.getColor(R.color.bg_mode_step));
            applyStatusBarTintRes(R.color.bg_mode_step);
        } else {
            findViewById(R.id.backView).setBackgroundColor(this.f9056H.getColor(R.color.bg_mode_unbind));
            applyStatusBarTintRes(R.color.bg_mode_unbind);
        }
        m13927q();
        m13928r();
        m13933t();
        m13935u();
        bT bt = new bT(this);
        this.mSlidingUpPanelLayout.post(bt);
        m13885a(getIntent());

        if ((personInfo.height) == -1 || (personInfo.gender == -1) || (personInfo.birthday.equals(""))) {
            // we need to get all these information
            Keeper.saveCurrentUser(Keeper.CURRENT_USER_NAME, personInfo.nickname);
            Keeper.saveCurrentUser(Keeper.CURRENT_USER_ID, String.valueOf(personInfo.uid));
            intent = new Intent(ScaleActivity.this, MemberInfoSetGenderActivity.class);
            startActivity(intent);
        }

    }

    public void onDestroy() {
        super.onDestroy();
        this.mHandler.removeCallbacksAndMessages(null);
        this.mHandler = null;
        if (this.mBroadcastReceiver != null) {
            unregisterReceiver(this.mBroadcastReceiver);
            this.mBroadcastReceiver = null;
        }
//        if (this.f9054F.f4207q.f4231a.booleanValue()) {
//            this.f9049A.m11474b();
//        }
        GuliLog.tracePrintInfo(TAG, "onDestroy");
    }

    public void onEvent(EventApkupgrade eventApkupgrade) {
        GuliLog.m12370d(TAG, "onEvent, force=" + eventApkupgrade.isForceCheck() + " HasWindowfocus=" + hasWindowFocus());
        if (this.f9069n) {
            Utils.m8039b((Activity) this, eventApkupgrade.isForceCheck());
        }
    }

    public void onEvent(EventBtOnOff eventBtOnOff) {
        GuliLog.tracePrintInfo(TAG, "onBtOnOff:" + eventBtOnOff.type);
        if (eventBtOnOff.type == f9032J) {
            this.f9072q = true;
            if (this.mDynamicFragment != null) {
                this.mDynamicFragment.m14463a(Boolean.valueOf(true));
            }
            refreshListAndDetectBlank(true);
            m13903e((int) f9037O);
        } else if (eventBtOnOff.type == 0 && this.f9072q) {
            this.f9072q = false;
            this.mHandler.sendEmptyMessage(f9035M);
        }
    }

    class cl implements Runnable {
        final /* synthetic */ ck f9830a;

        cl(ck ckVar) {
            this.f9830a = ckVar;
        }

        public void run() {
            this.f9830a.f9829a.updateUI(false);
        }
    }

    class ck implements Runnable {
        final /* synthetic */ ScaleActivity f9829a;

        ck(ScaleActivity mainUIActivity) {
            this.f9829a = mainUIActivity;
        }

        public void run() {
            this.f9829a.runOnUiThread(new cl(this));
        }
    }

    public void onEvent(EventDynamicDetailSleepUserModified eventDynamicDetailSleepUserModified) {
        new Thread(new ck(this)).start();
    }

//    public void onEvent(EventGameUpdate eventGameUpdate) {
//        GuliLog.tracePrintInfo(TAG, "EventGameUpdate: " + eventGameUpdate);
//        LuaEvent.getInstance(this).callLuaFunc("showGameBanner", eventGameUpdate);
//        runOnUiThread(new ci(this));
//    }

    public void onEvent(EventGoalsUpdated eventGoalsUpdated) {
        GuliLog.tracePrintInfo(TAG, "onEvent, EventGoalsUpdated");
        DataManager.m12179a().m12240s();
        Utils.m8099t(this.mContext);
        m13960l();
    }

    public void onEvent(EventHomeListLoad eventHomeListLoad) {
        if (eventHomeListLoad != null && eventHomeListLoad.success) {
            refreshListAndDetectBlank(true);
        }
    }

    public void onEvent(EventLuaUpdated eventLuaUpdated) {
        clearLuaDb(true);
    }

    public void onEvent(EventPersonInfoUpdateUnit eventPersonInfoUpdateUnit) {
        clearLuaDb(true);
    }

    public void onEvent(EventUseManualLazyDay eventUseManualLazyDay) {
        DimPanelFragment.showPanel((Activity) this, UseLazyDaysFragment.class);
    }

    static public class UseLazyDaysFragment extends DimPanelFragment implements View.OnClickListener { // fn
        private static final String TAG = "UseLazyDaysFragment";

        protected int inflateLayout() {
            return R.layout.fragment_confirm_lazyday;
        }

        public void onCreate(Bundle bundle) {
            super.onCreate(bundle);
        }

        public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
            return super.onCreateView(layoutInflater, viewGroup, bundle);
        }

        protected void onLeftButtonClicked() {
            super.onLeftButtonClicked();
            dismiss();
        }

        protected void onRightButtonClicked() {
            super.onRightButtonClicked();
            dismiss();
            C0668a.m8126a(getActivity(), C0668a.fg);
            Utils.m7989a(new SportDay());
            Context activity = getActivity();
            if (activity != null) {
                Utils.m8098s(activity);
                ScaleActivity mainUIActivity = (ScaleActivity) activity;
                if (mainUIActivity != null) {
                    mainUIActivity.m13960l();
                }
            }
        }
    }

    class cp implements Runnable {
        final /* synthetic */ ScaleActivity f9834a;

        cp(ScaleActivity mainUIActivity) {
            this.f9834a = mainUIActivity;
        }

        public void run() {
            this.f9834a.updateUI(true);
        }
    }

    class cq implements Runnable {
        final /* synthetic */ ScaleActivity f9835a;

        cq(ScaleActivity mainUIActivity) {
            this.f9835a = mainUIActivity;
        }

        public void run() {
            this.f9835a.updateUI(true);
        }
    }

    public void onEvent(EventWeightTargetUpdated eventWeightTargetUpdated) {
        int i = eventWeightTargetUpdated.uid;
        GuliLog.tracePrintInfo(TAG, "target weight goal update " + i);
        LuaUtil.getInstance(this.mContext).m15960a(i);
        runOnUiThread(new cq(this));
//        if (!Utils.m8101v(this.mContext) && !Utils.m8102w(this.mContext)) {
//            Partner a = C0855b.m8954a(this.mContext).m8957a("2833961550");
//            a.title = getString(R.string.bohee_title);
//            a.subTitle = getString(R.string.bohee_subtitle);
//            LuaEvent.getInstance(this.mContext).showLuaItem(PartnerDataManager.buildLuaItem(a));
//        }
    }

    public void onEvent(EventUserChanged eventUserChanged) {
        GuliLog.tracePrintInfo(TAG, "EventUserChanged : " + eventUserChanged.uid);
        this.mDynamicFragment.m14461a(eventUserChanged.uid, true);
    }

    public void onEvent(EventUserDeleted eventUserDeleted) {
        int i = eventUserDeleted.uid;
        GuliLog.tracePrintInfo(TAG, "EventUserDeleted " + i);
        this.mDynamicFragment.m14461a(i, false);
        runOnUiThread(new cp(this));
    }

    class co implements Runnable {
        final /* synthetic */ ScaleActivity f9833a;

        co(ScaleActivity mainUIActivity) {
            this.f9833a = mainUIActivity;
        }

        public void run() {
            this.f9833a.updateUI(true);
        }
    }

    public void onEvent(EventWeightChanged eventWeightChanged) {
        GuliLog.tracePrintInfo(TAG, "EventWeightChanged : " + eventWeightChanged.uids + ", forceUpdate : " + eventWeightChanged.forceUpdate);
        if (eventWeightChanged.uids != null && eventWeightChanged.uids.length > 0) {
            int[] iArr = eventWeightChanged.uids;
            int length = iArr.length;
            for (int i = f9037O; i < length; i += f9032J) {
                this.mDynamicFragment.m14461a(iArr[i], eventWeightChanged.forceUpdate);
            }
        }
        runOnUiThread(new co(this));
    }

    public void onEvent(EventWeightSyncedDevice eventWeightSyncedDevice) {
        GuliLog.tracePrintInfo(TAG, "EventWeightSyncedDevice : " + eventWeightSyncedDevice.forceUpdate + ", " + eventWeightSyncedDevice.uid);
        WeightUtil.m15712b((Context) this);
    }

    public void onEvent(EventWeightSyncedServer eventWeightSyncedServer) {
        GuliLog.tracePrintInfo(TAG, "EventWeightSyncedServer : " + eventWeightSyncedServer.state);
        if (eventWeightSyncedServer.state == f9032J) {
            this.mDynamicFragment.m14464a(false);
        }
    }

    public void onEvent(ThirdTokenState thirdTokenState) {
        runOnUiThread(new cj(this, thirdTokenState));
    }

    class cj implements Runnable {
        final /* synthetic */ ThirdTokenState f9827a;
        final /* synthetic */ ScaleActivity f9828b;

        cj(ScaleActivity mainUIActivity, ThirdTokenState thirdTokenState) {
            this.f9828b = mainUIActivity;
            this.f9827a = thirdTokenState;
        }

        public void run() {
            GuliLog.tracePrintInfo("MainUIActivity", "ThirdTokenState:" + this.f9827a);
            if (this.f9827a.accountType == 1) {
                LuaUtil.getInstance(this.f9828b).setWeiboToken(this.f9827a.isExpired);
                this.f9828b.refreshListAndDetectBlank(false);
            }
        }
    }

    public void onEvent(HwBatteryStatus hwBatteryStatus) {
        if (hwBatteryStatus != null) {
            GuliLog.tracePrintInfo(TAG, "EventBatteryStatus onEvent: status = " + hwBatteryStatus.f19644e + ", charges =" + hwBatteryStatus.f19645f);
            if (hwBatteryStatus.f19644e == f9032J) {
                this.f9071p = true;
            } else {
                this.f9071p = false;
            }
            m13956h();
        }
    }

    public void onEvent(HwConnStatus hwConnStatus) {
        GuliLog.tracePrintInfo(TAG, "HwConnStatus:" + hwConnStatus + ",type = " + hwConnStatus.m25399b());
        if (hwConnStatus.m25399b().m25103b() == DataManager.m12179a().m12239r()) {
            if (!hwConnStatus.m25399b().equals(this.mHwConnStatus.m25399b())) {
                this.av = false;
                this.au = false;
            }
            if (this.ae == null || this.mDynamicFragment == null) {
                GuliLog.tracePrintInfo(TAG, "HwConnStatus: mDynamicListUpdateTip is null" + hwConnStatus);
            } else if (hwConnStatus.m25399b().m25104c()) {
                m13896b(hwConnStatus);
            } else if (C3843c.SHOES.equals(hwConnStatus.m25399b())) {
                m13890a(hwConnStatus);
            }
            this.mHwConnStatus = hwConnStatus;
            GuliLog.tracePrintInfo(TAG, "out HwConnStatus:" + hwConnStatus);
        }
    }

    public void onEvent(HwSyncDataStatus hwSyncDataStatus) {
        GuliLog.tracePrintInfo(TAG, "HwSyncDataStatus:" + hwSyncDataStatus + ",type = " + hwSyncDataStatus.m25421h());
        if (hwSyncDataStatus.m25421h().m25103b() == DataManager.m12179a().m12239r()) {
            this.mHwSyncDataStatus = hwSyncDataStatus;
            String string = getString(R.string.dynamic_pull_syncing);
            String str = C3657a.f18328f;
            if (hwSyncDataStatus.m25415b()) {
                this.mHandler.removeMessages(f9036N);
                Object[] objArr = new Object[f9032J];
                objArr[f9037O] = Integer.valueOf(f9037O);
                m13892a(string, getString(R.string.dynamic_pull_syncing_progress, objArr));
            } else if (hwSyncDataStatus.m25416c()) {
                Object[] objArr2 = new Object[f9032J];
                objArr2[f9037O] = Integer.valueOf(Math.max(f9037O, Math.min(f9043U, hwSyncDataStatus.m25419f())));
                m13892a(string, getString(R.string.dynamic_pull_syncing_progress, objArr2));
            } else if (hwSyncDataStatus.m25417d()) {
                if (hwSyncDataStatus.m25420g()) {
                    m13851I();
                    m13879Y();
//                    m13880Z();
                    Utils.m8099t(this.mContext);
                    GuliLog.tracePrintInfo(TAG, "Sync step data to Google Fit");
                } else {
                    m13893a(getString(R.string.dynamic_pull_sync_error), Utils.m7976a((Context) this, (int) R.string.dynamic_pull_last_sync_time), f9039Q, 0.0f);
                }
            }
            GuliLog.tracePrintInfo(TAG, "out HwSyncDataStatus");
        }
    }

    class cr implements Runnable {
        final /* synthetic */ ScaleActivity f9836a;

        cr(ScaleActivity mainUIActivity) {
            this.f9836a = mainUIActivity;
        }

        public void run() {
            this.f9836a.updateUI(true);
        }
    }

    public void onEventBackgroundThread(EventWeightWithUser eventWeightWithUser) {
        LuaUtil.getInstance(this.mContext).m15966b(UserInfoManager.getInstance().getInfoByUid(eventWeightWithUser.uid), eventWeightWithUser.mWeightAdvData);
        // then update the UI
        this.mDynamicFragment.m14461a(eventWeightWithUser.uid, true);
        runOnUiThread(new cr(this));
    }

    public void onEventMainThread(EventTimeChanged eventTimeChanged) {
        GuliLog.tracePrintInfo(TAG, "time changed");
        if (m13869R()) {
            set24HourFormat();
            refreshUI();
        }
    }

    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        GuliLog.tracePrintInfo(TAG, "onNewIntent:" + intent);
        m13885a(intent);
    }

    protected void onPause() {
        super.onPause();
        GuliLog.tracePrintInfo(TAG, "onPause");
        this.f9069n = false;
//        if (this.f9077v != null) {
//            this.f9077v.m12144d();
//        }
        C0668a.m8138b((Activity) this);
    }

    class cw implements Runnable {
        final /* synthetic */ cv f9841a;

        cw(cv cvVar) {
            this.f9841a = cvVar;
        }

        public void run() {
            this.f9841a.activity.m13944z();
        }
    }


    class cx implements Runnable {
        final /* synthetic */ cv f9842a;

        cx(cv cvVar) {
            this.f9842a = cvVar;
        }

        public void run() {
            if (Config.m8876h().f4204n.f4257a.booleanValue()) {
                Utils.m8013a(false);
            }
        }
    }


    class cv implements Runnable {
        final /* synthetic */ ScaleActivity activity;

        cv(ScaleActivity mainUIActivity) {
            this.activity = mainUIActivity;
        }

        public void run() {
            this.activity.mHandler.post(new cw(this));
            this.activity.mHandler.postDelayed(new cx(this), 10000);
        }
    }

    protected void onResume() {
        super.onResume();
        GuliLog.tracePrintInfo(TAG, "onResume");
        this.f9069n = true;
        this.mSlidingUpPanelLayout.post(new cv(this));
        if (DeviceSource.hasBindBracelet() || DeviceSource.hasBindShoesDevice()) {
            this.mSlidingUpPanelLayout.setPullDownEnabled(true);
        } else {
            this.mSlidingUpPanelLayout.setPullDownEnabled(false);
        }
        C0668a.m8124a((Activity) this);
        if (Utils.m8071g()) {
            C0668a.m8126a((Context) this, C0668a.eK);
        }
        if (Utils.m8069f()) {
            C0668a.m8126a((Context) this, C0668a.eL);
        }
//        if (!Keeper.readPersonInfo().getMiliVibrate()) {
//            C0668a.m8126a((Context) this, C0668a.eQ);
//        }
//        if (this.f9077v != null) {
//            this.f9077v.m12142b(C1429e.f7291b);
//        }
    }

    protected void onSaveInstanceState(Bundle bundle) {
    }

    public void onStop() {
        super.onStop();
        getWindow().setWindowAnimations(android.R.style.Animation_Activity); //(16973825);
    }

    protected void updateTitle(int i) {
        this.dynamicTitle.setText(i);
    }
}
